<?php

namespace app\adminapi\export;

use app\services\product\product\StoreProductServices;

class AgentMarketProductExport extends BaseExport
{
    protected $header = [
        '商品', '金额(元)', '库存', '总销量', '商品状态', '是否参与推广'
    ];

    public function createData(array $where)
    {
        $list = app()->make(StoreProductServices::class)->getMarketList($where)['list'];

        $data = [];

        foreach ($list as $item) {
            $data[] = [
                $item['store_name'] ?? '',
                $item['price'] ?? '',
                $item['stock'] ?? '',
                $item['sales'] ?? '',
                $item['is_show'] ? '上架' : '下架',
                $item['join_agent'] ? '是' : '否'
            ];
        }

        return $data;
    }
}